<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 方式一
    // function Vue () {

    // }
    // Vue.use = (plugin, options) => {
    //   if (typeof plugin === 'function') {
    //     plugin(Vue, options)
    //   } else {
    //     plugin.install(Vue, options)
    //   }
    // }

    // 方式二
    class Vue {
      constructor () {}
      static use (plugin, options) {
        if (typeof plugin === 'function') {
          plugin(Vue, options)
        } else {
          plugin.install(Vue, options)
        }
      }
      component () {}
    }

    const plugin1 = {
      install: (app, options) => {
        app.prototype.$plugin1 = '哈哈哈'
      }
    }
    const plugin2 = (app, options) => {
      app.prototype.$plugin2 = 'plugin2'
    }

    Vue.use(plugin1, {
      locale: ''
    })
    Vue.use(plugin2)

    console.log(Vue.prototype.$plugin1)
    console.log(Vue.prototype.$plugin2)
    console.log(Vue.prototype)
  </script>
</body>
</html>